package day03;

import java.util.Arrays;

public class ArrayReverseReturnNewArray {
	public static void main(String[] args) {
		int[] x = { 2, 8, 10, 12, 33 };
		int[] y=reverse(x);
		System.out.println("原数组x: "+Arrays.toString(x));
		System.out.println("返回的新数组: "+Arrays.toString(y));	
  }
	public static int[] reverse(int[] n) {
		int array[] = new int[n.length] ;
		for(int k = 0;k<n.length;k++) {
			array [k] = n[k];
		}
		int i;
		int j = 0;
		int length = n.length;
		for (i = 0; i < length / 2; i++) {
			j = array[i];
			array[i] = array[length - i - 1];
			array[length - i - 1] = j;
		}
		return array;
	}
}
